####################################################################################################
### Title: People Consistently View Elections and Civil Liberties as Key Components of Democracy ###
### Content: Removing ties                                                                       ###
### Date: August 24, 2024                                                                        ###
####################################################################################################

### Set-up ----
## Clean the working environment and set the working directory
rm(list = ls())
setwd("~/Desktop/Science_Replication/all_countries")

## Load the required packages
library(ggplot2)         # version 3.4.3
library(tidyverse)       # version 2.0.0
library(estimatr)        # version 1.0.0
library(cregg)           # version 0.4.0
library(expss)           # version 0.11.4
library(ggrepel)         # version 0.9.1
library(cowplot)         # version 1.1.1
library(survey)          # version 4.1.1

## Read the cleaned datasets
df_US <- read.csv("~/Desktop/Science_Replication/data_cleaning/df_US.csv")
df_JP <- read.csv("~/Desktop/Science_Replication/data_cleaning/df_JP.csv")
df_EG <- read.csv("~/Desktop/Science_Replication/data_cleaning/df_EG.csv")
df_IN <- read.csv("~/Desktop/Science_Replication/data_cleaning/df_IN.csv")
df_IT <- read.csv("~/Desktop/Science_Replication/data_cleaning/df_IT.csv")
df_TH <- read.csv("~/Desktop/Science_Replication/data_cleaning/df_TH.csv")

## Merge the datasets
df_cj <- bind_rows(df_US, df_JP, df_EG, df_IN, df_IT, df_TH)

## Reorder the factors
reorder_levels <- function(df_cj){
  # Electoral democracy
  df_cj$election <- 
    factor(df_cj$election, 
           levels = c("Elections are not held", "Elections are biased", "Elections are free and fair"))
  
  # Liberal democracy
  df_cj$civil <- 
    factor(df_cj$civil, 
           levels = c("Civil liberties are not at all protected", "Civil liberties are weakly protected", "Civil liberties are strongly protected"))
  
  # Institutional democracy
  df_cj$leader <- 
    factor(df_cj$leader, 
           levels = c("Leader is weakly constrained", "Leader is somewhat constrained", "Leader is highly constrained"))
  
  # Populist democracy
  df_cj$populist <- 
    factor(df_cj$populist, 
           levels = c("Leader rarely follows the majority", "Leader sometimes follows the majority", "Leader frequently follows the majority"))
  
  # Loyalist democracy
  df_cj$obedient <- 
    factor(df_cj$obedient, 
           levels = c("Dissidents mostly challenge the gov't", "Dissidents occasionally obey the gov't", "Dissidents mostly obey the gov't"))
  
  # Substantive democracy - economy
  df_cj$econ <- 
    factor(df_cj$econ, 
           levels = c("Economic equality is very low", "Economic equality is somewhat low", "Economic equality is high"))
  
  # Substantive democracy - gender
  df_cj$gender <- 
    factor(df_cj$gender, 
           levels = c("Gender equality is very low", "Gender equality is somewhat low", "Gender equality is high"))
  
  # Technocratic democracy
  df_cj$expert <- 
    factor(df_cj$expert, 
           levels = c("Experts have small influence on policy", "Experts have some influence on policy", "Experts have much influence on policy"))
  
  # Direct democracy
  df_cj$direct <- 
    factor(df_cj$direct, 
           levels = c("Policies are rarely voted on", "Policies are sometimes voted on", "Policies are frequently voted on"))
  
  return(df_cj)
}

df_cj <- reorder_levels(df_cj)

# Country
df_cj$country <- factor(df_cj$country, 
                        levels = c("US", "JP", "EG", "IN", "IT", "TH"),
                        labels = c("United States", "Japan", "Egypt", "India", "Italy", "Thailand"))

## Remove ties for each attribute
# Reshape the dataset first
df_cj$id.task <- paste0(df_cj$id, ".", df_cj$task)
df_wide <- df_cj %>% dplyr::select(id.task, profile, election, civil, leader, populist, obedient, econ, gender, expert, direct)
df_wide <- reshape(df_wide, idvar = "id.task", timevar = "profile", direction = "wide")

# Identify ties in the electoral democracy attribute, remove the ties, and reshape the data back to long form
df_wide$tie_election <- ifelse((df_wide$election.1 == df_wide$election.2), 1, 0)
df_no_election_ties <- df_wide %>% 
  filter(tie_election == 0) %>% 
  select(-tie_election)
df_no_election_ties <- df_no_election_ties %>% 
  pivot_longer(-id.task, 
               names_to = c(".value", "profile"),
               names_pattern = "(.+).(.+)")
df_no_election_ties$profile <- as.numeric(df_no_election_ties$profile)
df_no_election_ties$id <- substr(df_no_election_ties$id.task, 1, nchar(df_no_election_ties$id.task) - 2)
df_cj_merge <- df_cj %>% select(id.task, selected, profile)
df_no_election_ties <- left_join(df_no_election_ties, df_cj_merge, by = c("id.task", "profile"))

# Identify ties in the liberal democracy attribute, remove the ties, and reshape the data back to long form
df_wide <- df_wide %>% select(-tie_election)
df_wide$tie_liberal <- ifelse((df_wide$civil.1 == df_wide$civil.2), 1, 0)
df_no_liberal_ties <- df_wide %>% 
  filter(tie_liberal == 0) %>% 
  select(-tie_liberal)
df_no_liberal_ties <- df_no_liberal_ties %>% 
  pivot_longer(-id.task, 
               names_to = c(".value", "profile"),
               names_pattern = "(.+).(.+)")
df_no_liberal_ties$profile <- as.numeric(df_no_liberal_ties$profile)
df_no_liberal_ties$id <- substr(df_no_liberal_ties$id.task, 1, nchar(df_no_liberal_ties$id.task) - 2)
df_no_liberal_ties <- left_join(df_no_liberal_ties, df_cj_merge, by = c("id.task", "profile"))

# Identify ties in the institutional democracy attribute, remove the ties, and reshape the data back to long form
df_wide <- df_wide %>% select(-tie_liberal)
df_wide$tie_institution <- ifelse((df_wide$leader.1 == df_wide$leader.2), 1, 0)
df_no_institution_ties <- df_wide %>% 
  filter(tie_institution == 0) %>% 
  select(-tie_institution)
df_no_institution_ties <- df_no_institution_ties %>% 
  pivot_longer(-id.task, 
               names_to = c(".value", "profile"),
               names_pattern = "(.+).(.+)")
df_no_institution_ties$profile <- as.numeric(df_no_institution_ties$profile)
df_no_institution_ties$id <- substr(df_no_institution_ties$id.task, 1, nchar(df_no_institution_ties$id.task) - 2)
df_no_institution_ties <- left_join(df_no_institution_ties, df_cj_merge, by = c("id.task", "profile"))

# Identify ties in the populist democracy attribute, remove the ties, and reshape the data back to long form
df_wide <- df_wide %>% select(-tie_institution)
df_wide$tie_populist <- ifelse((df_wide$populist.1 == df_wide$populist.2), 1, 0)
df_no_populist_ties <- df_wide %>% 
  filter(tie_populist == 0) %>% 
  select(-tie_populist)
df_no_populist_ties <- df_no_populist_ties %>% 
  pivot_longer(-id.task, 
               names_to = c(".value", "profile"),
               names_pattern = "(.+).(.+)")
df_no_populist_ties$profile <- as.numeric(df_no_populist_ties$profile)
df_no_populist_ties$id <- substr(df_no_populist_ties$id.task, 1, nchar(df_no_populist_ties$id.task) - 2)
df_no_populist_ties <- left_join(df_no_populist_ties, df_cj_merge, by = c("id.task", "profile"))

# Identify ties in the loyalist democracy attribute, remove the ties, and reshape the data back to long form
df_wide <- df_wide %>% select(-tie_populist)
df_wide$tie_loyalist <- ifelse((df_wide$obedient.1 == df_wide$obedient.2), 1, 0)
df_no_loyalist_ties <- df_wide %>% 
  filter(tie_loyalist == 0) %>% 
  select(-tie_loyalist)
df_no_loyalist_ties <- df_no_loyalist_ties %>% 
  pivot_longer(-id.task, 
               names_to = c(".value", "profile"),
               names_pattern = "(.+).(.+)")
df_no_loyalist_ties$profile <- as.numeric(df_no_loyalist_ties$profile)
df_no_loyalist_ties$id <- substr(df_no_loyalist_ties$id.task, 1, nchar(df_no_loyalist_ties$id.task) - 2)
df_no_loyalist_ties <- left_join(df_no_loyalist_ties, df_cj_merge, by = c("id.task", "profile"))

# Identify ties in the substantive democracy (economy) attribute, remove the ties, and reshape the data back to long form
df_wide <- df_wide %>% select(-tie_loyalist)
df_wide$tie_economy <- ifelse((df_wide$econ.1 == df_wide$econ.2), 1, 0)
df_no_economy_ties <- df_wide %>% 
  filter(tie_economy == 0) %>% 
  select(-tie_economy)
df_no_economy_ties <- df_no_economy_ties %>% 
  pivot_longer(-id.task, 
               names_to = c(".value", "profile"),
               names_pattern = "(.+).(.+)")
df_no_economy_ties$profile <- as.numeric(df_no_economy_ties$profile)
df_no_economy_ties$id <- substr(df_no_economy_ties$id.task, 1, nchar(df_no_economy_ties$id.task) - 2)
df_no_economy_ties <- left_join(df_no_economy_ties, df_cj_merge, by = c("id.task", "profile"))

# Identify ties in the substantive democracy (gender) attribute, remove the ties, and reshape the data back to long form
df_wide <- df_wide %>% select(-tie_economy)
df_wide$tie_gender <- ifelse((df_wide$gender.1 == df_wide$gender.2), 1, 0)
df_no_gender_ties <- df_wide %>% 
  filter(tie_gender == 0) %>% 
  select(-tie_gender)
df_no_gender_ties <- df_no_gender_ties %>% 
  pivot_longer(-id.task, 
               names_to = c(".value", "profile"),
               names_pattern = "(.+).(.+)")
df_no_gender_ties$profile <- as.numeric(df_no_gender_ties$profile)
df_no_gender_ties$id <- substr(df_no_gender_ties$id.task, 1, nchar(df_no_gender_ties$id.task) - 2)
df_no_gender_ties <- left_join(df_no_gender_ties, df_cj_merge, by = c("id.task", "profile"))

# Identify ties in the technocratic democracy attribute, remove the ties, and reshape the data back to long form
df_wide <- df_wide %>% select(-tie_gender)
df_wide$tie_techno <- ifelse((df_wide$expert.1 == df_wide$expert.2), 1, 0)
df_no_techno_ties <- df_wide %>% 
  filter(tie_techno == 0) %>% 
  select(-tie_techno)
df_no_techno_ties <- df_no_techno_ties %>% 
  pivot_longer(-id.task, 
               names_to = c(".value", "profile"),
               names_pattern = "(.+).(.+)")
df_no_techno_ties$profile <- as.numeric(df_no_techno_ties$profile)
df_no_techno_ties$id <- substr(df_no_techno_ties$id.task, 1, nchar(df_no_techno_ties$id.task) - 2)
df_no_techno_ties <- left_join(df_no_techno_ties, df_cj_merge, by = c("id.task", "profile"))

# Identify ties in the direct democracy attribute, remove the ties, and reshape the data back to long form
df_wide <- df_wide %>% select(-tie_techno)
df_wide$tie_direct <- ifelse((df_wide$direct.1 == df_wide$direct.2), 1, 0)
df_no_direct_ties <- df_wide %>% 
  filter(tie_direct == 0) %>% 
  select(-tie_direct)
df_no_direct_ties <- df_no_direct_ties %>% 
  pivot_longer(-id.task, 
               names_to = c(".value", "profile"),
               names_pattern = "(.+).(.+)")
df_no_direct_ties$profile <- as.numeric(df_no_direct_ties$profile)
df_no_direct_ties$id <- substr(df_no_direct_ties$id.task, 1, nchar(df_no_direct_ties$id.task) - 2)
df_no_direct_ties <- left_join(df_no_direct_ties, df_cj_merge, by = c("id.task", "profile"))

### Figure S1A: AMCEs with the six-country sample after removing ties for each attribute ----
## Format attribute labels in plots
df_no_election_ties <- apply_labels(df_no_election_ties,
                                    election = "Electoral Democracy",
                                    civil = "Liberal Democracy",
                                    leader = "Institutional Democracy",
                                    populist = "Populist Democracy",
                                    obedient = "Loyalist Democracy",
                                    econ = "Substantive Democracy - Economy",
                                    gender = "Substantive Democracy - Gender",
                                    expert = "Technocratic Democracy",
                                    direct = "Direct Democracy")

attributes <- "election + civil + leader + populist + obedient + econ + gender + expert + direct"

## Bold feature labels in plots
bph <- c('bold', rep('plain', 3), 'bold', rep('plain', 3),
         'bold', rep('plain', 3), 'bold', rep('plain', 3), 
         'bold', rep('plain', 3), 'bold', rep('plain', 3),
         'bold', rep('plain', 3), 'bold', rep('plain', 3), 
         'bold', rep('plain', 3)) %>%
  rev() # reverse coding

## Estimate the AMCEs for election democracy
amces_election <- cj(data = df_no_election_ties,
                     formula = as.formula(paste("selected ~", attributes)),
                     id = ~id,
                     estimate = "amce")
amces <- amces_election

## Estimate the AMCEs for liberal democracy and merge them to the main data frame
amces_liberal <- cj(data = df_no_liberal_ties,
                    formula = as.formula(paste("selected ~", attributes)),
                    id = ~id,
                    estimate = "amce")
amces[4:6, 5:10] <- amces_liberal[4:6, 5:10]

## Estimate the AMCEs for institutional democracy and merge them to the main data frame
amces_institution <- cj(data = df_no_institution_ties,
                        formula = as.formula(paste("selected ~", attributes)),
                        id = ~id,
                        estimate = "amce")
amces[7:9, 5:10] <- amces_institution[7:9, 5:10]

## Estimate the AMCEs for populist democracy and merge them to the main data frame
amces_populist <- cj(data = df_no_populist_ties,
                        formula = as.formula(paste("selected ~", attributes)),
                        id = ~id,
                        estimate = "amce")
amces[10:12, 5:10] <- amces_populist[10:12, 5:10]

## Estimate the AMCEs for loyalist democracy and merge them to the main data frame and merge them to the main data frame
amces_loyalist <- cj(data = df_no_loyalist_ties,
                     formula = as.formula(paste("selected ~", attributes)),
                     id = ~id,
                     estimate = "amce")
amces[13:15, 5:10] <- amces_loyalist[13:15, 5:10]

## Estimate the AMCEs for substantive democracy (economy) and merge them to the main data frame
amces_economy <- cj(data = df_no_economy_ties,
                     formula = as.formula(paste("selected ~", attributes)),
                     id = ~id,
                     estimate = "amce")
amces[16:18, 5:10] <- amces_economy[16:18, 5:10]

## Estimate the AMCEs for substantive democracy (gender) and merge them to the main data frame
amces_gender <- cj(data = df_no_gender_ties,
                    formula = as.formula(paste("selected ~", attributes)),
                    id = ~id,
                    estimate = "amce")
amces[19:21, 5:10] <- amces_gender[19:21, 5:10]

## Estimate the AMCEs for technocratic democracy and merge them to the main data frame
amces_techno <- cj(data = df_no_techno_ties,
                   formula = as.formula(paste("selected ~", attributes)),
                   id = ~id,
                   estimate = "amce")
amces[22:24, 5:10] <- amces_techno[22:24, 5:10]

## Estimate the AMCEs for direct democracy and merge them to the main data frame
amces_direct <- cj(data = df_no_direct_ties,
                   formula = as.formula(paste("selected ~", attributes)),
                   id = ~id,
                   estimate = "amce")
amces[25:27, 5:10] <- amces_direct[25:27, 5:10]

## Create a function that indicates which estimates are statistically significant
## at the 5% level after using the BH procedure to adjust for multiple comparisons
sig1_fun <- function(data){
  data <- data %>% 
    mutate(sig = case_when(
      (p.adjust(p, method = "BH") < 0.05) == TRUE ~ 1, 
      (p.adjust(p, method = "BH") < 0.05) == FALSE ~ 0)) %>% 
    mutate(sig = factor(sig, levels = c(0, 1)))
  return(data)
}

## Apply the function to adjust for multiple comparisons
amces <- sig1_fun(amces)
amces$sig[is.na(amces$sig)] <- 0

## Visualize the AMCEs
p <- plot(amces, legend_pos = "none", size = 1) + 
  aes(color = sig) + 
  xlab("Effect on Pr(Being Selected as More Democratic)")
p <- p + scale_color_manual(values = c("grey60", "black"))
p <- p + theme_bw(base_size = 10, base_family = "Times") %+replace%
  theme(
    axis.text.x = element_text(size = 9, colour = "black",  hjust = .5, vjust = 1),
    axis.text.y = element_text(size = 9, colour = "black", hjust = 1, vjust = .5, face = bph),
    axis.ticks = element_line(colour = "grey50"),
    axis.title.y = element_text(size = 9, angle = 90, vjust = .01, hjust = .1),
    legend.position = "none",
    strip.text.x = element_text(size = 8),
    panel.grid.major.x = element_blank(),
    panel.grid.minor.x = element_blank()
  )
p_amce <- p + coord_cartesian(xlim = c(-0.03, 0.27))

### Figure S1B: attribute salience with the six-country sample after removing ties for each attribute ----
## Estimate the salience score of electoral democracy
# Reshape data
df_salience_election <- df_no_election_ties %>% 
  mutate_if(is.factor, as.character) %>% 
  gather("attribute", "level", 3:11)

# Calculate the salience score
salience_election <- df_salience_election %>% 
  group_by(attribute, level) %>% 
  summarize(average = mean(selected)) %>%
  ungroup() %>% 
  mutate(deviation = abs(average - 0.5)) %>% 
  group_by(attribute) %>% 
  summarize(salience_mean = mean(deviation))
salience <- salience_election

## Estimate the salience score of liberal democracy
# Reshape data
df_salience_liberal <- df_no_liberal_ties %>% 
  mutate_if(is.factor, as.character) %>% 
  gather("attribute", "level", 3:11)

# Calculate the salience score and merge it to the main data frame
salience_liberal <- df_salience_liberal %>% 
  group_by(attribute, level) %>% 
  summarize(average = mean(selected)) %>%
  ungroup() %>% 
  mutate(deviation = abs(average - 0.5)) %>% 
  group_by(attribute) %>% 
  summarize(salience_mean = mean(deviation))
salience[1, 2] <- salience_liberal[1, 2]

## Estimate the salience score of institutional democracy
# Reshape data
df_salience_institution <- df_no_institution_ties %>% 
  mutate_if(is.factor, as.character) %>% 
  gather("attribute", "level", 3:11)

# Calculate the salience score and merge it to the main data frame
salience_institution <- df_salience_institution %>% 
  group_by(attribute, level) %>% 
  summarize(average = mean(selected)) %>%
  ungroup() %>% 
  mutate(deviation = abs(average - 0.5)) %>% 
  group_by(attribute) %>% 
  summarize(salience_mean = mean(deviation))
salience[7, 2] <- salience_institution[7, 2]

## Estimate the salience score of populist democracy
# Reshape data
df_salience_populist <- df_no_populist_ties %>% 
  mutate_if(is.factor, as.character) %>% 
  gather("attribute", "level", 3:11)

# Calculate the salience score and merge it to the main data frame
salience_populist <- df_salience_populist %>% 
  group_by(attribute, level) %>% 
  summarize(average = mean(selected)) %>%
  ungroup() %>% 
  mutate(deviation = abs(average - 0.5)) %>% 
  group_by(attribute) %>% 
  summarize(salience_mean = mean(deviation))
salience[9, 2] <- salience_institution[9, 2]

## Estimate the salience score of loyalist democracy
# Reshape data
df_salience_loyalist <- df_no_loyalist_ties %>% 
  mutate_if(is.factor, as.character) %>% 
  gather("attribute", "level", 3:11)

# Calculate the salience score and merge it to the main data frame
salience_loyalist <- df_salience_loyalist %>% 
  group_by(attribute, level) %>% 
  summarize(average = mean(selected)) %>%
  ungroup() %>% 
  mutate(deviation = abs(average - 0.5)) %>% 
  group_by(attribute) %>% 
  summarize(salience_mean = mean(deviation))
salience[8, 2] <- salience_institution[8, 2]

## Estimate the salience score of substantive democracy (economy)
# Reshape data
df_salience_economy <- df_no_economy_ties %>% 
  mutate_if(is.factor, as.character) %>% 
  gather("attribute", "level", 3:11)

# Calculate the salience score and merge it to the main data frame
salience_economy <- df_salience_economy %>% 
  group_by(attribute, level) %>% 
  summarize(average = mean(selected)) %>%
  ungroup() %>% 
  mutate(deviation = abs(average - 0.5)) %>% 
  group_by(attribute) %>% 
  summarize(salience_mean = mean(deviation))
salience[3, 2] <- salience_economy[3, 2]

## Estimate the salience score of substantive democracy (gender)
# Reshape data
df_salience_gender <- df_no_gender_ties %>% 
  mutate_if(is.factor, as.character) %>% 
  gather("attribute", "level", 3:11)

# Calculate the salience score and merge it to the main data frame
salience_gender <- df_salience_gender %>% 
  group_by(attribute, level) %>% 
  summarize(average = mean(selected)) %>%
  ungroup() %>% 
  mutate(deviation = abs(average - 0.5)) %>% 
  group_by(attribute) %>% 
  summarize(salience_mean = mean(deviation))
salience[6, 2] <- salience_gender[6, 2]

## Estimate the salience score of technocratic democracy
# Reshape data
df_salience_techno <- df_no_techno_ties %>% 
  mutate_if(is.factor, as.character) %>% 
  gather("attribute", "level", 3:11)

# Calculate the salience score and merge it to the main data frame
salience_techno <- df_salience_techno %>% 
  group_by(attribute, level) %>% 
  summarize(average = mean(selected)) %>%
  ungroup() %>% 
  mutate(deviation = abs(average - 0.5)) %>% 
  group_by(attribute) %>% 
  summarize(salience_mean = mean(deviation))
salience[5, 2] <- salience_techno[5, 2]

## Estimate the salience score of direct democracy
# Reshape data
df_salience_direct <- df_no_direct_ties %>% 
  mutate_if(is.factor, as.character) %>% 
  gather("attribute", "level", 3:11)

# Calculate the salience score and merge it to the main data frame
salience_direct <- df_salience_direct %>% 
  group_by(attribute, level) %>% 
  summarize(average = mean(selected)) %>%
  ungroup() %>% 
  mutate(deviation = abs(average - 0.5)) %>% 
  group_by(attribute) %>% 
  summarize(salience_mean = mean(deviation))
salience[2, 2] <- salience_direct[2, 2]

## Visualize the estimates
# Rename the attributes
salience$attribute <- 
  case_match(salience$attribute, 
             "election" ~ "Electoral\nDemocracy",
             "civil" ~ "Liberal\nDemocracy",
             "leader" ~ "Institutional\nDemocracy",
             "populist" ~ "Populist\nDemocracy",
             "obedient" ~ "Loyalist\nDemocracy",
             "econ" ~ "Substantive\nDemocracy\n(Economy)",
             "gender" ~ "Substantive\nDemocracy\n(Gender)",
             "expert" ~ "Technocratic\nDemocracy",
             "direct" ~ "Direct\nDemocracy")

# Reorder the attributes
salience$attribute <- 
  factor(salience$attribute,
         levels = c("Electoral\nDemocracy", 
                    "Liberal\nDemocracy", 
                    "Institutional\nDemocracy", 
                    "Populist\nDemocracy", 
                    "Loyalist\nDemocracy",
                    "Substantive\nDemocracy\n(Economy)", 
                    "Substantive\nDemocracy\n(Gender)", 
                    "Technocratic\nDemocracy", 
                    "Direct\nDemocracy"))

p_salience <- ggplot(data = salience) +
  geom_point(aes(x = fct_rev(attribute), y = salience_mean),
             size = 2, shape = 8) + 
  coord_flip(ylim = c(0, 0.1)) +
  labs(y = "Attribute Salience", x = NULL) +
  scale_y_continuous(n.breaks = 3) +
  theme_bw(base_size = 10, base_family = "Times") %+replace%
  theme(
    axis.text.x = element_text(size = 9, colour = "black", hjust = .5, vjust = 1),
    axis.text.y = element_text(size = 9, colour = "black", face = "bold", hjust = 1, vjust = .5),
    axis.ticks = element_line(colour = "grey50"),
    strip.text.x = element_text(size = 9),
    panel.grid.major.x = element_blank(),
    panel.grid.minor.x = element_blank()
  )

## Combine the plot with the aggregate AMCE plot
p_amce <- p_amce + ggtitle("Estimated AMCEs") +
  theme(plot.title = element_text(hjust = 0.5, size = 11, face = "italic"))
p_salience <- p_salience + ggtitle("Attribute Salience") + 
  theme(plot.title = element_text(hjust = 0.5, size = 11, face = "italic"))
plot_grid(p_amce, p_salience, labels = "AUTO", nrow = 1, 
          label_fontfamily = "Times", label_size = 11,
          rel_widths = c(2, 1))
ggsave("Figure S1.pdf", width = 8, height = 6)
